package com.taotao.search.listener;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.springframework.beans.factory.annotation.Autowired;

import com.taotao.search.service.SearchItemService;

public class ItemChangeListener implements MessageListener {
	
	@Autowired
	private SearchItemService searchItemService;

	@Override
	public void onMessage(Message message) {
		if(message instanceof TextMessage) {
			TextMessage textMessage = (TextMessage) message;
			try {
				//获取消息内容
				Long itemId = Long.parseLong(textMessage.getText());
				searchItemService.updateItemById(itemId);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}

}
